export function fileSizeFitler(val) {
	if (val === 0) {
		return '0 B';
	} else {
		const k = 1024;
		const sizes = ['B', 'KB', 'MB', 'GB', 'PB', 'TB', 'EB', 'ZB', 'YB'];
		let index = Math.floor(Math.log(val) / Math.log(k));
		return (val / Math.pow(k, index)).toPrecision(3) + '' + sizes[index];
	}
}
export function timeRemainFilter(val) {
	let text = '上传剩余时间：'
	let dateNum = val === Infinity ? 0 : val;
	let hour = Math.floor(dateNum / 3600 % 24);
	let minute = Math.floor(dateNum / 60 % 60);
	let seconds = Math.floor(dateNum % 60);
	if (hour > 0) {
		return `${text}${hour} 时 ${minute} 分 ${seconds} 秒`
	} else if (minute > 0) {
		return `${text}${minute} 分 ${seconds} 秒`
	} else if (seconds > 0) {
		return `${text}${seconds} 秒`
	}
}
